﻿<UserControl x:Class="Soat.HappyNet.Silverlight.Modules.Production.Views.ProductDetailView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:windowControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"             
    xmlns:regions="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:controls="clr-namespace:Soat.HappyNet.Silverlight.Library.Controls;assembly=Soat.HappyNet.Silverlight.Library"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:behavior="clr-namespace:Soat.HappyNet.Silverlight.Library.Behaviors;assembly=Soat.HappyNet.Silverlight.Library"
    xmlns:action="clr-namespace:Soat.HappyNet.Silverlight.Library.Behaviors.Actions;assembly=Soat.HappyNet.Silverlight.Library"
    xmlns:trigger="clr-namespace:Soat.HappyNet.Silverlight.Library.Behaviors.Triggers;assembly=Soat.HappyNet.Silverlight.Library"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:imgtools="clr-namespace:ImageTools.Controls;assembly=ImageTools.Controls">
    <Grid x:Name="LayoutRoot">
        <toolkit:HeaderedContentControl Header="{Binding Path=Strings.PRODUCTION_ProductDetails, Source={StaticResource LocalizedStrings}}"
                                        Style="{StaticResource HeaderedContentStyle}">
            <Grid Margin="4,0,4,0"
                  VerticalAlignment="Top">

                <i:Interaction.Behaviors>
                    <behavior:BoolValueVisibilityBehavior 
                                    ValueBinding="{Binding IsProductLoaded}" />
                </i:Interaction.Behaviors>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="10" />
				    <RowDefinition Height="Auto" />
                    <RowDefinition Height="10" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="10" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid Grid.Row="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="5" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock x:Name="ProductTitle" 
					           Text="{Binding Name}"
					           HorizontalAlignment="Center" 
					           TextAlignment="Center"
                               TextWrapping="Wrap"
                               Style="{StaticResource ProductsTitleStyle}"/>
                    <TextBlock Grid.Row="2"
					           Text="{Binding Price}"
					           HorizontalAlignment="Center" 
					           TextAlignment="Center"
                               TextWrapping="Wrap"
                               FontSize="18"
                               Style="{StaticResource ProductsTitleStyle}"/>
                </Grid>
                
                <Grid Grid.Row="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition MaxHeight="100" />
                    </Grid.RowDefinitions>
                    
                    <Grid Grid.Row="0">
                        <ComboBox ItemsSource="{Binding Products}"
                                  HorizontalAlignment="Center"
                                  MinWidth="140"
                                  SelectedItem="{Binding CurrentProduct, Mode=TwoWay}"
                                  Style="{StaticResource ComboBoxStyle}">
                            <i:Interaction.Behaviors>
                                <behavior:BoolValueVisibilityBehavior 
                                    ValueBinding="{Binding IsMultiProducts}" />
                            </i:Interaction.Behaviors>
                            <ToolTipService.ToolTip>
                                <ToolTip Style="{StaticResource ToolTipStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding CurrentProduct.Name}" />
                                    </StackPanel>
                                </ToolTip>
                            </ToolTipService.ToolTip>
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <!--<Rectangle Width="5" Height="5" 
                                                   Margin="0,0,5,0"
                                                   Fill="{Binding Color, Converter={StaticResource ColorConverter}}">
                                            <i:Interaction.Behaviors>
                                                <behavior:BoolValueVisibilityBehavior ValueBinding="{Binding Color}" />
                                            </i:Interaction.Behaviors>
                                        </Rectangle>-->
                                        <TextBlock Text="{Binding Name}" />
                                    </StackPanel>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </Grid>

                    <Border Grid.Row="2"
                            Margin="10"
                            CornerRadius="6,0,0,0"
                            BorderBrush="{StaticResource DefaultBorderBrush}"
                            BorderThickness="2"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center">
                        <Grid>
                            <imgtools:AnimatedImage 
                                    Stretch="Uniform"
                                    x:Name="ProductImage">
                                <i:Interaction.Behaviors>
                                    <behavior:ClippingBehavior CornerRadius="6,0,0,0" />
                                </i:Interaction.Behaviors>
                            </imgtools:AnimatedImage>

                            <Grid Background="Transparent"
                                  Cursor="Hand">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MouseLeftButtonDown">
                                        <action:ExecuteCommandAction Command="{Binding ShowPhotoGalleryCommand}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <ToolTipService.ToolTip>
                                    <ToolTip Style="{StaticResource ToolTipStyle}" 
                                     Content="{Binding Strings.PRODUCTION_ShowGallery, Source={StaticResource LocalizedStrings}}"/>
                                </ToolTipService.ToolTip>
                                <Border IsHitTestVisible="False"
                                        HorizontalAlignment="Right"
                                        VerticalAlignment="Bottom"
                                        CornerRadius="6,0,0,0"
                                        Background="#40000000"
                                        Width="18"
                                        Height="18">
                                    <TextBlock Text="+"
                                               FontSize="13"
                                               HorizontalAlignment="Center"
                                               VerticalAlignment="Center"
                                               FontWeight="Bold"
                                               Foreground="White"/>
                                </Border>
                            </Grid>
                        </Grid>
                    </Border>
                </Grid>

                <ScrollViewer Style="{StaticResource ScrollViewerStyle}"
                              ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                              Grid.Row="4">
                    <Grid VerticalAlignment="Top">
                        <!--<TextBlock Text="{Binding Description}"
                                   Style="{StaticResource LabelStyle}"/>-->
                        <TextBox Text="{Binding Description}"
                                 Style="{StaticResource LabelBoxStyle}" />
                    </Grid>
                </ScrollViewer>

                <Grid Grid.Row="6"
                      VerticalAlignment="Top">
                    <Button Content="{Binding Strings.PRODUCTION_AddToCart, Source={StaticResource LocalizedStrings}}"
                            HorizontalAlignment="Right"
                            Padding="18,4"
                            Style="{StaticResource ButtonStyle}"
                            cal:Click.Command="{Binding AddToCardCommand}"
                            cal:Click.CommandParameter="{Binding CurrentProduct}">
                        <Button.Background>
                            <SolidColorBrush Color="{StaticResource TitleHeaderColor}"  />
                        </Button.Background>
                    </Button>
                </Grid>
                
            </Grid>
        </toolkit:HeaderedContentControl>
        
        <controls:Loading IsLoading="{Binding IsLoading}"
                          Width="40" Height="40"/>
    </Grid>
</UserControl>
    